package jdk.thread.lock;

import java.util.concurrent.locks.Lock;

public class ReentrantTest {


    static Lock lock = new MyReentrantLock();

    public static void main(String[] args) throws InterruptedException {

        for(int i=0; i<5; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    test();
                }
            }).start();
        }


        Thread.sleep(10000l);

    }

    public static void test(){
        lock.lock();
        repetition();
        lock.unlock();
    }

    public static void repetition(){
        System.out.println("进入R方法中....");
        lock.lock();
        for(int i=0; i<10; i++) {
            System.out.println("进入R循环中...");
        }
        lock.unlock();
    }
}

